//
//  ZXZHomeMoreViewController.m
//  sheyingzu
//
//  Created by tyu on 29.5.24.
//

#import "ZXZHomeMoreViewController.h"

#import "ZXZGoodsView.h"
#import "ZXZHomeGoodsViewController.h"

@interface ZXZHomeMoreViewController ()

@property(nonatomic,weak) ZXZGoodsView *goodsView1;
@property(nonatomic,weak) ZXZGoodsView *goodsView2;
@property(nonatomic,weak) ZXZGoodsView *goodsView3;

@property(nonatomic,weak) UIScrollView *ScrollView;

@end

@implementation ZXZHomeMoreViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    
}


- (void)bac_addUI
{
    [super bac_addUI];
    [self setupView];
    self.bacTitleLabel.text = @"商品";
    [self.view bringSubviewToFront:self.navView];

}

- (void)setupView
{

    UIScrollView *ScrollV = [[UIScrollView alloc]init];
    [self.view addSubview:ScrollV];
    self.ScrollView =ScrollV;

    ScrollV.contentSize = CGSizeMake(ScreenWidth, ScreenHeight*1.5);
    ScrollV.contentInset = UIEdgeInsetsMake(0, 0, -10, 0);
    ScrollV.showsVerticalScrollIndicator = NO;
    ScrollV.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight-ShowDiff);


    CGFloat width = (ScreenWidth-30)/2;

    
    for (int i=0; i<3; i++) {
        
        ZXZGoodsView *goods = [[ZXZGoodsView alloc]init];
        [self.ScrollView addSubview:goods];
        if (i==0) {
            goods.ImgV.image = [UIImage imageNamed:@"goods1"];
            goods.TitleLab.text = @"Insta360 x4";
            goods.SubLab.text = @"专业摄像";
            goods.imageWidth = width;

            self.goodsView1 = goods;
            goods.ClcikBlock = ^(NSString * _Nonnull Str) {
                [self pushIndex:1];

            };
        }else if (i==1){
            goods.ImgV.image = [UIImage imageNamed:@"GoPro_02"];
            goods.TitleLab.text = @"GoPro";
            goods.SubLab.text = @"专业防抖";
            goods.imageWidth = width;

            self.goodsView2 = goods;
            goods.ClcikBlock = ^(NSString * _Nonnull Str) {
                [self pushIndex:2];

            };
        }else{
            goods.ImgV.image = [UIImage imageNamed:@"DJI_03"];
            goods.TitleLab.text = @"DJI";
            goods.SubLab.text = @"全景摄像";
            goods.imageWidth = width;

            self.goodsView3 = goods;
            goods.ClcikBlock = ^(NSString * _Nonnull Str) {
                [self pushIndex:3];
                
            };
        }
    }
    
    
    
    CGFloat height = 270;

    self.goodsView1.frame = CGRectMake(10, 70, width, height);
    self.goodsView2.frame = CGRectMake(CGRectGetMaxX(self.goodsView1.frame)+10, CGRectGetMinY(self.goodsView1.frame), width, height);
    self.goodsView3.frame = CGRectMake(10, CGRectGetMaxY(self.goodsView1.frame)+10, width, height);

    
    
}


- (void)pushIndex:(int)index
{
    ZXZHomeGoodsViewController *vc = [ZXZHomeGoodsViewController new];
    vc.index = index;
    [self.navigationController pushViewController:vc animated:YES];
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
